import {
  Slider,
  Input, Switch, Color, selectPageVarAndCustom, UploadImage
} from '@/components/CustomPage/fields/widget'
import { fontFamilyColorSize } from './fontFamilyColorSize'
export function cellTitleOps() {
  return [
    {
      type: Switch,
      option: {
        label: '是否展示标题名称',
        name: 'isShowModuleName',
        value: false,
        activetext: '是',
        inactivetext: '否',
        override: function(ths, e) {
          ths.$nextTick(() => {
            for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
              const name = ths.$parent.$parent.$children[i].option.name
              const nameList = [
                'compHeight',
                'moduleName',
                'backgroundColor',
                'radiusSize',
                'titleColor',
                'titleImage',
                'titleWidth',
                'height',
                'iconImage',
                'iconheight',
                'iconWidth'
              ]
              if (nameList.indexOf(name) > -1) {
                ths.$parent.$parent.$children[i].visible = e
              }
            }
          })
        }
      }
    },
    {
      type: selectPageVarAndCustom,
      option: {
        label: '标题名称',
        name: 'moduleName',
        value: '',
        allowcreate: true,
        clearable: true,
        filterable: true
      }
    },
    {
      type: Color,
      option: {
        label: '标题背景颜色',
        name: 'backgroundColor',
        value: 'rgba(255, 255, 255, 0)',
        showalpha: true
      }
    },
    {
      type: Slider,
      option: {
        label: '标题高度',
        name: 'compHeight',
        value: 98,
        max: 400,
        step: 1
      }
    },
    {
      type: Slider,
      option: {
        label: '组件标题圆角',
        name: 'radiusSize',
        value: 20,
        max: 45,
        step: 1
      }
    },
    // { type: Color, option: { label: '标题颜色', name: 'titleColor', value: '#fff', showalpha: true }},
    ...fontFamilyColorSize(),
    { type: UploadImage, option: { label: '标题背景图', name: 'titleImage' } },
    {
      type: Slider,
      option: {
        label: '标题背景图宽',
        name: 'titleWidth',
        value: 98,
        max: 750,
        step: 1
      }
    },
    {
      type: Slider,
      option: {
        label: '标题背景图高',
        name: 'height',
        value: 98,
        max: 400,
        step: 1
      }
    },
    { type: UploadImage, option: { label: 'icon图', name: 'iconImage' } },
    {
      type: Slider,
      option: {
        label: 'icon图高度',
        name: 'iconheight',
        value: 40,
        max: 400,
        step: 1
      }
    },
    {
      type: Slider,
      option: {
        label: 'icon图宽度',
        name: 'iconWidth',
        value: 40,
        max: 400,
        step: 1
      }
    }
  ]
}

export function titleOps() {
  return [
    {
      type: Switch,
      option: {
        label: '是否展示标题名称',
        name: 'isShowModuleName',
        value: true,
        activetext: '是',
        inactivetext: '否',
        override: function(ths, e) {
          ths.$nextTick(() => {
            for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
              const name = ths.$parent.$parent.$children[i].option.name
              const nameList = [
                'compHeight',
                'moduleName',
                'backgroundColor',
                'radiusSize',
                'titleColor',
                'titleImage',
                'titleWidth',
                'height',
                'iconImage',
                'iconheight',
                'iconWidth'
              ]
              if (nameList.indexOf(name) > -1) {
                ths.$parent.$parent.$children[i].visible = e
              }
            }
          })
        }
      }
    },
    {
      type: selectPageVarAndCustom,
      option: {
        label: '标题名称',
        name: 'moduleName',
        value: '',
        allowcreate: true,
        clearable: true,
        filterable: true
      }
    },
    // { type: Slider, option: { label: '组件高度', name: 'compHeight', value: 98, max: 200, step: 1 }},
    {
      type: Color,
      option: {
        label: '标题背景颜色',
        name: 'backgroundColor',
        value: 'rgba(255, 255, 255, 0)',
        showalpha: true
      }
    },
    {
      type: Slider,
      option: {
        label: '组件高度',
        name: 'compHeight',
        value: 98,
        max: 400,
        step: 1
      }
    },
    // { type: Color, option: { label: '标题颜色', name: 'titleColor', value: '#fff', showalpha: true }},
    ...fontFamilyColorSize(),
    { type: UploadImage, option: { label: '标题背景图', name: 'titleImage' } },
    {
      type: Slider,
      option: {
        label: '标题背景图宽',
        name: 'titleWidth',
        value: 98,
        max: 750,
        step: 1
      }
    },
    {
      type: Slider,
      option: {
        label: '标题背景图高',
        name: 'height',
        value: 98,
        max: 400,
        step: 1
      }
    },
    { type: UploadImage, option: { label: 'icon图', name: 'iconImage' } },
    {
      type: Slider,
      option: {
        label: 'icon图高度',
        name: 'iconheight',
        value: 40,
        max: 98,
        step: 1
      }
    },
    {
      type: Slider,
      option: {
        label: 'icon图宽度',
        name: 'iconWidth',
        value: 40,
        max: 98,
        step: 1
      }
    }
  ]
}
